[LegacyColorValue = true]; 

{ TSMIntRateParity : Interest rate parity
   Copyright 1999, P.J.Kaufman. All rights reserved.

   This program calculates the forward rate of the first currency
	(i.e., Deutsche mark) based on the spot rate and the 1-year
	maturity interest rates, and the same information for a second
	series (i.e., Swiss franc). Each currency must be denominated
	in the same third currency (i.e., US dollars)

   Inputs:	data1 is the spot price of the first currency
			data2 is the n-month interest rate of the first currency
			data3 is the n-month interest rate of the second currency
			nmonths is the maturity "n" of interest rates, in months
			nforward is the number of days forward to find fx rate
			rtype is rate type, 0=yield, 1=3-mo price (futures), 
				2=bond price (futures) }

	inputs: nmonths(3), nforward(90), rtype(2);
	vars:	frate1(0), frate2(0), conv(0), parity(0), rate1(0), rate2(0),
			par(8.00);

{  check type of rate value }
	rate1 = close of data2;
	rate2 = close of data3;
	if rtype = 1 then begin
		rate1 = 100 - rate1;
		rate2 = 100 - rate2;
		end
	else if rtype = 2 then begin
		rate1 = par / rate1;
		rate2 = par / rate2;
		end;
{  change interest rate to forward target }
	conv = nforward / (365 / 12);
	frate1 =rate1*conv / nmonths;
	frate2 = rate2*conv / nmonths;
	parity = close of data1 * ( (1 + frate1) / (1 + frate2));
	plot1(parity, "TSMparity");	